<template>
  <div class="header">
    <div class="logo" @click="goToBack">
      <img :src="'static/img/unboxingDetail/logo_light.png'" alt="" />
    </div>
    <div class="price-content">
      <img :src="'static/img/unboxingDetail/coins_y.png'" alt="" />
      <span>{{balance}}</span>
      <div class="price-add" @click="goToPayment">
        <span class="icon iconfont add">&#xe6db;</span>
      </div>
    </div>
    <div class="menu-btn" @click.stop="showMenu">
      <span class="icon iconfont menu">&#xe6c0;</span>
    </div>
  </div>
</template>

<script>
export default {
  data(){
    return{
      balance:3.9
    }
  },
  mounted(){
    let old =  this.balance
    this.balance -=1
    setInterval(() => {
      if (old <= this.balance ) {
        return
        
      }
      this.balance+=0.02
     this.balance = Number(this.balance.toFixed(2))
    }, 30);
  },
  methods: {
    goToBack() {
      this.$router.go(-1);
    },
    goToPayment(){
      
       this.$router.push({
              name:"payment"
          })
    },
    showMenu() {
      this.$emit("showMenu");
    },
  },
};
</script>

<style lang="scss" scoped>
.header {
  position: fixed;
  left: 0;
  top: 0;
  right: 0;
  z-index: 999;
  height: 95px;
  display: flex;
  justify-content: space-evenly;
  align-items: center;
  padding: 0 16px;
  padding-top: calc(0px);
  background-color: var(--nav-bc);
  border-bottom: 1px solid var(--main-color-0_1_1);
  .logo {
    img {
      height: 60px;
      width: 60px;
    }
  }
  .price-content {
    border: 1px solid var(--price-border);
    margin-right: 13px;
    min-width: 218px;
    height: 51px;
    border-radius: 5px;
    display: flex;
    justify-content: flex-start;
    align-items: center;
    img {
      width: 30px;
      height: 30px;
      margin-left: 6px;
      margin-right: 6px;
    }
    span {
      font-size: 19px;
      font-weight: bold;
      color: rgb(252, 198, 45);
    }
    .price-add {
      width: 40px;
      height: 40px;
      border-radius: 5px;
      margin-left: auto;
      margin-right: 6px;
      background: linear-gradient(98deg, #f48836, #f4364c 100%);
      display: flex;
      justify-content: center;
      align-items: center;
      .add {
        font-size: 32px;
        line-height: 24px;
        font-weight: normal;
        top: 0px;
        color: rgb(255, 255, 255);
      }
    }
  }
  .menu-btn {
    width: 54px;
    height: 54px;
    display: flex;
    justify-content: center;
    align-items: center;
    border: 1px solid var(--text-color);
    opacity: 0.85;
    border-radius: 2px;
    .menu {
      color: var(--menu-color);
      font-size: 32px;
    }
  }
}
</style>